/**
 * 
 */
package com.cipe.cmrs.controllers;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.cipe.cmrs.model.Cipeprojectstatus;
import com.cipe.cmrs.service.CipeprojectstatusService;

/**
 * @author Incepio
 *
 */
@Controller
public class CipeprojectstatusController extends BaseController {

	/**
	 * 
	 */
	private static final long			serialVersionUID	= -3823562098119817733L;
	@Autowired
	private CipeprojectstatusService	cipeprojectstatusService;

	@RequestMapping("/secure/showAddCipeprojectstatus.do")
	public String showAddCipeprojectstatus(Model model) {
		model.addAttribute("cipeprojectstatus", new Cipeprojectstatus());
		return "editCipeprojectstatus";
	}

	@RequestMapping("/secure/showEditCipeprojectstatus.do")
	public String showEditCipeprojectstatus(@RequestParam Integer id, Model model) {
		model.addAttribute("cipeprojectstatus", cipeprojectstatusService.findById(id));
		return "editCipeprojectstatus";
	}

	@RequestMapping("/secure/saveCipeprojectstatus.do")
	public String SaveCipeprojectstatus(@ModelAttribute("cipeprojectstatus") Cipeprojectstatus cipeprojectstatus, BindingResult result, Model model, HttpServletRequest request) {
		try {
			cipeprojectstatus = cipeprojectstatusService.saveCipeprojectstatus(cipeprojectstatus, getUserId(request));
			saveMessage(request, getText("editCipeprojectstatus.message.success"));
		} catch (Exception e) {
			logger.error(getText("error.transaction"), e);
			saveError(request, getText("error.transaction"));
		}
		model.addAttribute("cipeprojectstatus", cipeprojectstatus);
		return "editCipeprojectstatus";
	}

	@RequestMapping("/secure/showCipeprojectstatusList.do")
	public String showCipeprojectstatusList(Model model) {
		model.addAttribute("cipeprojectstatuses", cipeprojectstatusService.findAll());
		return "cipeprojectstatusList";
	}
}
